<template>
	<view class="content">
		<uinput type="textarea" v-model="content" height="500" tlposition="none" :maxlength="-1" placeholder="请输入吐槽内容">
		</uinput>
		<button type="primary" size="default" @click="markSpeak">吐槽</button>
	</view>
</template>

<script>
	import uinput from "../../../components/poiuy-uinput/uinput.vue";
	export default {
		components: {
			uinput
		},
		data() {
			return {
				content: ""
			};
		},
		onLoad() {
			this.content = "";
		},
		methods: {
			markSpeak() {
				console.log(this.content);
				var t = this;
				uni.getStorage({
					key: 'token',
					success: function(storage) {
						var json = JSON.parse(storage.data.message);
						uni.request({
							url: "http://localhost:4567/user_json/markSpeak.json",
							header: {
								"token": storage.data.tokenName,
							},
							data: {
								"userId": json.id,
								"content": t.content
							},
							method: "POST",
							success: (res) => {
								uni.showModal({
									title: '提示',
									content: "吐槽成功",
									success: function(res) {
										if (res.confirm) {
											uni.navigateBack();
										} else if (res.cancel) {
											console.log('用户点击取消');
										}
									}
								});
							},
							fail: (res) => {}
						});
					},
					fail: function(res) {
						uni.navigateTo({
							url: '/pages/login/login'
						});
					}
				});
			}
		}
	};
</script>
<style lang="less" scoped></style>
